<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>有趣的算法问题之巧思妙想 | Jin Tian</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  
  
  
  <meta name="description" content="本文介绍 有趣的算法问题之巧思妙想">
<meta property="og:type" content="article">
<meta property="og:title" content="有趣的算法问题之巧思妙想">
<meta property="og:url" content="http://yoursite.com/2017/09/06/有趣的算法问题之巧思妙想/index.html">
<meta property="og:site_name" content="Jin Tian">
<meta property="og:description" content="本文介绍 有趣的算法问题之巧思妙想">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2017-09-06T09:03:31.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="有趣的算法问题之巧思妙想">
<meta name="twitter:description" content="本文介绍 有趣的算法问题之巧思妙想">
  
    <link rel="alternate" href="/atom.xml" title="Jin Tian" type="application/atom+xml">
  

  

  <link rel="icon" href="/css/images/mylogo.jpg">
  <link rel="apple-touch-icon" href="/css/images/mylogo.jpg">
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
  <link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");font-weight:lighter;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");font-weight:400;font-style:italic;}</style>
  <link rel="stylesheet" href="/css/style.css">

  <script src="/js/jquery-3.1.1.min.js"></script>
  <script src="/js/bootstrap.js"></script>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="/css/bootstrap.css" >

  
    <link rel="stylesheet" href="/css/dialog.css">
  

  

  
    <link rel="stylesheet" href="/css/header-post.css" >
  

  
  
  
    <link rel="stylesheet" href="/css/vdonate.css" >
  

</head>



  <body data-spy="scroll" data-target="#toc" data-offset="50">


  
  <div id="container">
    <div id="wrap">
      
        <header>

    <div id="allheader" class="navbar navbar-default navbar-static-top" role="navigation">
        <div class="navbar-inner">
          
          <div class="container"> 
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>

            
              <a class="brand" style="
                 border-width: 0px;  margin-top: 0px;"  
                href="#" data-toggle="modal" data-target="#myModal" >
                  <img width="124px" height="124px" alt="Hike News" src="/css/images/mylogo.jpg">
              </a>
            
            
            <div class="navbar-collapse collapse">
              <ul class="hnav navbar-nav">
                
                  <li> <a class="main-nav-link" href="/">首页</a> </li>
                
                  <li> <a class="main-nav-link" href="/archives">归档</a> </li>
                
                  <li> <a class="main-nav-link" href="/categories">分类</a> </li>
                
                  <li> <a class="main-nav-link" href="/tags">标签</a> </li>
                
                  <li> <a class="main-nav-link" href="/about">关于</a> </li>
                
                  <li> <a class="main-nav-link" href="http://luoli-luoli.com/chat">chat</a> </li>
                
                  <li><div id="search-form-wrap">

    <form class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="" />
        <button type="submit" class="search-form-submit"></button>
    </form>
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="请输入关键词..." />
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(无标题)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/js/insight.js"></script>

</div></li>
            </div>
          </div>
                
      </div>
    </div>

</header>



      
            
      <div id="content" class="outer">
        
          <section id="main" style="float:none;"><article id="post-有趣的算法问题之巧思妙想" style="width: 75%; float:left;" class="article article-type-post" itemscope itemprop="blogPost" >
  <div id="articleInner" class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="thumb" class="article-title" itemprop="name">
      有趣的算法问题之巧思妙想
    </h1>
  

      </header>
    
    <div class="article-meta">
      
	<a href="/2017/09/06/有趣的算法问题之巧思妙想/" class="article-date">
	  <time datetime="2017-09-06T01:09:09.000Z" itemprop="datePublished">2017-09-06</time>
	</a>

      
    <a class="article-category-link" href="/categories/默认分类/">默认分类</a>

      
	<a class="article-views">
	<span id="busuanzi_container_page_pv">
		阅读量<span id="busuanzi_value_page_pv"></span>
	</span>
	</a>

    </div>
    <div class="article-entry" itemprop="articleBody">
      
        <p>本文介绍 有趣的算法问题之巧思妙想<br><a id="more"></a></p>
<h1 id="有趣的算法问题之巧思妙想"><a href="#有趣的算法问题之巧思妙想" class="headerlink" title="有趣的算法问题之巧思妙想"></a>有趣的算法问题之巧思妙想</h1><blockquote>
<p>本文由在当地较为英俊的男子金天大神原创，版权所有，欢迎转载，本文首发地址 <a href="https://jinfagang.github.io" target="_blank" rel="noopener">https://jinfagang.github.io</a> 。但请保留这段版权信息，多谢合作，有任何疑问欢迎通过微信联系我交流：<code>jintianiloveu</code></p>
</blockquote>
<h2 id="有趣的算法"><a href="#有趣的算法" class="headerlink" title="有趣的算法"></a>有趣的算法</h2><p>算法之所以有趣，在于他能够化繁为简，他能概括统御世间万物，将一个复杂的问题归结为一个非常简单的问题。其实所有高阶的算法，都可以用两个大的方法去解决，而且屡试不爽。分别是<strong>动态规划</strong>和<strong>贪心算法</strong>.<br>我们先从一道动态规划的问题先说起吧。</p>
<h3 id="动态规划问题"><a href="#动态规划问题" class="headerlink" title="动态规划问题"></a>动态规划问题</h3><blockquote>
<p>最长公共子序列问题(LCS)，给定两个序列X和Y，求他们之间最长的公共子序列。</p>
</blockquote>
<p>哇，这题目感觉有点难啊。最长公共子序列问题其实可以归结为最最最最最简单的一个递推表达式，首先我们假设序列X元素个数为i，Y为j，C[i, j]表示最长公共子序列的长度。好那么问题就变成了，如何求取这个最长公共子序列的长度问题。公式也是非常简单 ==easy==  :smile:</p>
<p>$$C[i, j] = \left{ \begin{array}{lr} 0,\quad if \   x=0 \,  or \   y=0 \ C[i-1, j-1] + 1, \quad if \; i,j&gt;0 \; , x_i=y_i \ max{C[i, j-1], C[i-1, j]} , \quad if \ i,j&gt;0, \ x_i\neq x_j \end{array} \right. $$</p>
<p>这个公式还是非常难打啊，大概就是这么一个意思吧。咋一看这个表达式很牛逼啊，你随便给我两个序列，我通过他就可以求出最长子序列的长度？闲话不多说，让我们直接上代码看一下到底有没有这么牛逼。</p>
<p>假如我们有两个序列，我们用字符串来表示吧 X=cnblogs, Y=belong, 肉眼可以看到最长子序列为blog。那么长度就是4，让我们看看到底有没有这么牛逼。</p>
<p>在这之前，我得理清一下思路，首先是这样的，我们求取的这个C[i, j]，实际上就是一个二维的矩阵，你想啊i是从0变到i，j是从0变到j，那一路求过来，不就是一个i行j列的矩阵吗？目标值就是最右下角的这个元素。既然如此那么变成就好办了。</p>
<figure class="highlight c++"><table><tr><td class="code"><pre><div class="line"><span class="comment">// this code calculate the max length of common sub-sequence of 2 strings</span></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">lcs_length</span><span class="params">(<span class="built_in">string</span> a, <span class="built_in">string</span> b)</span> </span>&#123;</div><div class="line">    <span class="comment">// given 2 string, return the LCS length</span></div><div class="line">    <span class="comment">// define a 2 dim array</span></div><div class="line">    <span class="keyword">int</span> matrix[a.size()+<span class="number">1</span>][b.size()+<span class="number">1</span>];</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt;= a.size(); ++i) &#123;</div><div class="line">        matrix[i][<span class="number">0</span>] = <span class="number">0</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt;= b.size(); ++j) &#123;</div><div class="line">        matrix[<span class="number">0</span>][j] = <span class="number">0</span>;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= a.size(); i++) &#123;</div><div class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">1</span>; j &lt;= b.size(); j++) &#123;</div><div class="line">            <span class="keyword">if</span> (a[i<span class="number">-1</span>] == b[j<span class="number">-1</span>]) &#123;</div><div class="line">                matrix[i][j] = matrix[i<span class="number">-1</span>][j<span class="number">-1</span>] + <span class="number">1</span>;</div><div class="line">            &#125; <span class="keyword">else</span> &#123;</div><div class="line">                matrix[i][j] = matrix[i][j<span class="number">-1</span>] &gt; matrix[i<span class="number">-1</span>][j] ? matrix[i][j<span class="number">-1</span>] : matrix[i<span class="number">-1</span>][j];</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> matrix[a.size()][b.size()];</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>很显然，这个函数可以正确的得到最长公共子串的长度。看上去还是很牛逼，但是其实道理也非常简单，无外乎就是上面的三个公式。那么你可能回问了，上面三个公式是怎么来的呢？其实就是一个非常简单的递推，假如说公共子串Z的最后一个元素是X的最后一个元素，那么肯定也是Y的最后元素，那如果将X去掉最后元素，Y去掉最后一个元素，最长公共子串就是去掉之后的+1，就是加去掉的这个嘛。那如果说最后一个元素都不是X， Y的最后元素，那更好办了，这个时候公共子串就是X和Y的中间某一个子串嘛，这个时候X去掉最后一个，再来求公共子串，还是一样啊，或者Y去掉一个，也是一样啊，就直接就等于X或者Y去掉一个的共同子串的最大值了。(有人会问，为什么不等于X，Y都去掉一个的最大值呢？也就是 $$ max{C[i-1, j-1], C[i-1, j-1]}$$， 这是不行的，原因很简单，你X去掉一个之后，最长子串就有可能包含Y的最后一个值了，你都去掉会减少很多种情况，不可取 )。</p>
<p>这个问题我们已经完成了历史性的一步： <strong>可以求取两个序列的最长子序列的长度。</strong>， 那么下一步就是，怎么找到这个最长子序列。这一步思路是这样的：</p>
<p>(你可能无法想象，我完成求最大公共子序列上调试C++代码踩了一下午坑，我曹，真的是天坑)。先说一下思路吧，非常复杂，首先在上面的函数里面我们给他传入一个pFlag的二维数组，注意这是一个指针，因为后面需要递归遍历他。在这个二维数组里面存储的大小和matrix是一样，只不过这里面存储的都是字符串，为了便于理解我存储为 : “left”, “up”, “left_up”，三种字符串，其实你如果自己画了matrix这个表，就会发现，其实可以通过这样的箭头去回溯这个最长子序列是什么，你会发现恰恰是箭头所指向的路径。然后我们用一个函数递归，根据箭头来找到对应的子序列。所有代码如下：</p>
<figure class="highlight c++"><table><tr><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">sub_sequence</span><span class="params">(<span class="keyword">int</span> i, <span class="keyword">int</span> j, <span class="built_in">string</span> **pFlag, <span class="built_in">string</span> a)</span> </span>&#123;</div><div class="line">    <span class="keyword">if</span> (i == <span class="number">0</span> || j == <span class="number">0</span>) &#123;</div><div class="line">        <span class="keyword">return</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">if</span> (pFlag[i][j] == <span class="string">"left_up"</span>) &#123;</div><div class="line">        sub_sequence(i - <span class="number">1</span>, j - <span class="number">1</span>, pFlag, a);</div><div class="line">        <span class="built_in">cout</span> &lt;&lt; a[i<span class="number">-1</span>] &lt;&lt; <span class="string">" "</span>;</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">if</span> (pFlag[i][j] == <span class="string">"left"</span>) &#123;</div><div class="line">            sub_sequence(i, j<span class="number">-1</span>, pFlag, a);</div><div class="line">        &#125; <span class="keyword">else</span> &#123;</div><div class="line">            sub_sequence(i<span class="number">-1</span>, j, pFlag, a);</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">lcs_length</span><span class="params">(<span class="built_in">string</span> a, <span class="built_in">string</span> b, <span class="built_in">string</span> **pFlag)</span> </span>&#123;</div><div class="line">    <span class="comment">// given 2 string, return the LCS length</span></div><div class="line">    <span class="comment">// define a 2 dim array</span></div><div class="line">    <span class="keyword">int</span> matrix[a.size()+<span class="number">1</span>][b.size()+<span class="number">1</span>];</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt;= a.size(); ++i) &#123;</div><div class="line">        matrix[i][<span class="number">0</span>] = <span class="number">0</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt;= b.size(); ++j) &#123;</div><div class="line">        matrix[<span class="number">0</span>][j] = <span class="number">0</span>;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= a.size(); i++) &#123;</div><div class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">1</span>; j &lt;= b.size(); j++) &#123;</div><div class="line">            <span class="keyword">if</span> (a[i<span class="number">-1</span>] == b[j<span class="number">-1</span>]) &#123;</div><div class="line">                matrix[i][j] = matrix[i<span class="number">-1</span>][j<span class="number">-1</span>] + <span class="number">1</span>;</div><div class="line">                <span class="comment">// using string to indicate location</span></div><div class="line">                pFlag[i][j] = <span class="string">"left_up"</span>;</div><div class="line">            &#125; <span class="keyword">else</span> &#123;</div><div class="line">                <span class="keyword">if</span> (matrix[i][j<span class="number">-1</span>] &gt; matrix[i<span class="number">-1</span>][j]) &#123;</div><div class="line">                    matrix[i][j] = matrix[i][j<span class="number">-1</span>];</div><div class="line">                    pFlag[i][j] = <span class="string">"left"</span>;</div><div class="line">                &#125; <span class="keyword">else</span> &#123;</div><div class="line">                    matrix[i][j] = matrix[i<span class="number">-1</span>][j];</div><div class="line">                    pFlag[i][j] = <span class="string">"up"</span>;</div><div class="line">                &#125;</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> matrix[a.size()][b.size()];</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></div><div class="line">&#123;</div><div class="line">    <span class="built_in">string</span> b = <span class="string">"gheteuponthiop"</span>;</div><div class="line">    <span class="built_in">string</span> a = <span class="string">"giothuphyo"</span>;</div><div class="line">    <span class="comment">// 这里应该是**pFlag, markdown渲染有问题，二维指针</span></div><div class="line">    <span class="keyword">auto</span> ** pFlag = <span class="keyword">new</span> <span class="built_in">string</span>* [a.size() + <span class="number">1</span>];</div><div class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> k = <span class="number">0</span>; k &lt;= a.size(); ++k) &#123;</div><div class="line">        pFlag[k] = <span class="keyword">new</span> <span class="built_in">string</span>[b.size() + <span class="number">1</span>];</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">int</span> l = lcs_length(a, b, pFlag);</div><div class="line">    sub_sequence((<span class="keyword">int</span>) a.size(), (<span class="keyword">int</span>) b.size(), pFlag, a);</div><div class="line">    <span class="built_in">cout</span> &lt;&lt; <span class="built_in">endl</span>;</div><div class="line">    <span class="built_in">cout</span> &lt;&lt; l &lt;&lt; <span class="built_in">endl</span>;</div><div class="line">    <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>收工！以后遇到求最大公共子序列问题就来我的博客！！！！</p>
<p>写到这里发现并不是那么有趣了。很复杂啊。。。不过坚信那句，万变不离其宗。</p>

      
    </div>
    <footer class="article-footer">
      
        <div id="donation_div"></div>

<script src="/js/vdonate.js"></script>
<script>
var a = new Donate({
  title: '骚年，加个好友打赏一下啊，现在连泡面都吃不起了啊', // 可选参数，打赏标题
  btnText: '打赏支持', // 可选参数，打赏按钮文字
  el: document.getElementById('donation_div'),
  wechatImage: 'https://i.loli.net/2017/09/27/59cb048ba6838.jpeg',
  alipayImage: 'https://i.loli.net/2017/09/27/59cb049cd0951.jpeg'
});
</script>
      
      
        
	<div id="comment">
		<!-- 来必力City版安装代码 -->
		<div id="lv-container" data-id="city" data-uid="MTAyMC8zMDA5MC82NjQ1">
		<script type="text/javascript">
		   (function(d, s) {
		       var j, e = d.getElementsByTagName(s)[0];

		       if (typeof LivereTower === 'function') { return; }

		       j = d.createElement(s);
		       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
		       j.async = true;

		       e.parentNode.insertBefore(j, e);
		   })(document, 'script');
		</script>
		<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
		</div>
		<!-- City版安装代码已完成 -->
	</div>



      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2017/09/06/有趣的算法问题之真的有趣吗/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">上一篇</strong>
      <div class="article-nav-title">
        
          有趣的算法问题之真的有趣吗
        
      </div>
    </a>
  
  
    <a href="/2017/09/04/算法终章：遗失的那一部分/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">下一篇</strong>
      <div class="article-nav-title">算法终章：遗失的那一部分</div>
    </a>
  
</nav>

  
</article>

<!-- Table of Contents -->

  <aside id="toc-sidebar">
    <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录</strong>
    
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#有趣的算法问题之巧思妙想"><span class="nav-number">1.</span> <span class="nav-text">有趣的算法问题之巧思妙想</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#有趣的算法"><span class="nav-number">1.1.</span> <span class="nav-text">有趣的算法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#动态规划问题"><span class="nav-number">1.1.1.</span> <span class="nav-text">动态规划问题</span></a></li></ol></li></ol></li></ol>
    
    </div>
  </aside>
</section>
        
      </div>
      
      <footer id="footer">
  

  <div class="container">
      	<div class="row">
	      <p> Powered by <a href="http://www.luoli-luoli.com/" target="_blank">萝莉萝莉</a> and <a href="http://www.luoli-luoli.com/sia" target="_blank">Sia</a> </p>
	      <p id="copyRightEn">Copyright &copy; 2017 - 2018 Jin Tian All Rights Reserved.</p>
	      
	      
    		<p class="busuanzi_uv">
				访客数 : <span id="busuanzi_value_site_uv"></span> |  
				访问量 : <span id="busuanzi_value_site_pv"></span>
		    </p>
  		   
		</div>

		
  </div>
</footer>


<!-- min height -->

<script>
    var wrapdiv = document.getElementById("wrap");
    var contentdiv = document.getElementById("content");
    var allheader = document.getElementById("allheader");

    wrapdiv.style.minHeight = document.body.offsetHeight + "px";
    if (allheader != null) {
      contentdiv.style.minHeight = document.body.offsetHeight - allheader.offsetHeight - document.getElementById("footer").offsetHeight + "px";
    } else {
      contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("footer").offsetHeight + "px";
    }
</script>
    </div>
    <!-- <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/categories" class="mobile-nav-link">Categories</a>
  
    <a href="/tags" class="mobile-nav-link">Tags</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
    <a href="http://luoli-luoli.com/chat" class="mobile-nav-link">Chat</a>
  
</nav> -->
    

<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/scripts.js"></script>




  <script src="/js/dialog.js"></script>








	<div style="display: none;">
    <script src="https://s95.cnzz.com/z_stat.php?id=1260716016&web_id=1260716016" language="JavaScript"></script>
  </div>



	<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
	</script>






  </div>

  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h2 class="modal-title" id="myModalLabel">设置</h2>
      </div>
      <hr style="margin-top:0px; margin-bottom:0px; width:80%; border-top: 3px solid #000;">
      <hr style="margin-top:2px; margin-bottom:0px; width:80%; border-top: 1px solid #000;">


      <div class="modal-body">
          <div style="margin:6px;">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" onclick="javascript:setFontSize();" aria-expanded="true" aria-controls="collapseOne">
              正文字号大小
            </a>
          </div>
          <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
          <div class="panel-body">
            您已调整页面字体大小
          </div>
        </div>
      


          <div style="margin:6px;">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" onclick="javascript:setBackground();" aria-expanded="true" aria-controls="collapseTwo">
              夜间护眼模式
            </a>
        </div>
          <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
          <div class="panel-body">
            夜间模式已经开启，再次单击按钮即可关闭 
          </div>
        </div>

        <div>
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="true" aria-controls="collapseThree">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;关 于&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
        </div>
         <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
          <div class="panel-body">
            Jin Tian
          </div>
          <div class="panel-body">
            Copyright © 2018 Jintian All Rights Reserved.
          </div>
        </div>
      </div>


      <hr style="margin-top:0px; margin-bottom:0px; width:80%; border-top: 1px solid #000;">
      <hr style="margin-top:2px; margin-bottom:0px; width:80%; border-top: 3px solid #000;">
      <div class="modal-footer">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
      </div>
    </div>
  </div>
</div>
  
  <a id="rocket" href="#top" class=""></a>
  <script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
  
    <a id="menu-switch"><i class="fa fa-bars fa-lg"></i></a>
  
</body>
</html>